package com.sh.ssao.lottery.choujiang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sh.ssao.lottery.choujiang.bean.BachInfo;
import com.sh.ssao.lottery.choujiang.mapper.BachInfoMapper;
import com.sh.ssao.lottery.choujiang.service.IBachInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 抽奖批次 服务实现类
 * </p>
 *
 * @author gzgs
 * @since 2022-12-08 15:27:40
 */
@Service
public class BachInfoServiceImpl extends ServiceImpl<BachInfoMapper, BachInfo> implements IBachInfoService {

        @Autowired
        BachInfoMapper mapper;

        /**
         * 抽奖批次分页查询数据
         * @param page
         * @param queryWrapper
         */
        @Override
        public IPage< BachInfo> listPage(Page page, QueryWrapper queryWrapper){
             return mapper.listPage(page,queryWrapper);
        }

        /**
         * 抽奖批次导出数据
         * @param queryWrapper
         */
        @Override
        public List<Map<String, Object>> export(QueryWrapper queryWrapper){
            return mapper.export(queryWrapper);
        }

        /**
         * 抽奖批次保存数据
         * @param bean
         */
        @Transactional
        @Override
        public void saveMore( BachInfo bean){
             mapper.insert(bean);
        }

        /**
         * 抽奖批次修改数据
         * @param bean
         */
        @Transactional
        @Override
        public void updateMore( BachInfo bean){
            mapper.updateById(bean);
        }

        /**
         * 抽奖批次删除数据
         * @param bean
         */
        @Override
        public void delMore( BachInfo bean){
             QueryWrapper< BachInfo> queryWrapper=new QueryWrapper<>();
             queryWrapper.eq("bach_id",bean.getBachId());
               mapper.delete(queryWrapper);
        }

}
